package com.bootcamp.jacase.lambda;

/**
 * @program: LambdaCode
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-04 14:49
 **/

public class TestLambda {
    public static void main(String[] args) {
        int returnValue = 555;
        INoReturnNoParam nrnp1 = () -> System.out.println("no return no para!");
        INoReturnOneParam nrop2 = (a) -> System.out.println("no return 1 para: " + a);
        INoReturnTwoParam nrtp3 = (a, b) -> System.out.println(a + " + " + b + " = " + (a + b));
        IHasReturnNoParam hrnp4 = () -> returnValue;
        IHasReturnOneParam hrop5 = (a) -> returnValue * a;
        IHasReturnTwoParam hrtp6 = (a, b) -> returnValue * (a + b);

        nrnp1.test();
        nrop2.test(22);
        nrtp3.test(31,33);
        System.out.println(hrnp4.test());
        System.out.println(hrop5.test(55));
        System.out.println(hrtp6.test(62,66));
    }
}

//无返回值无参数的功能接口
@FunctionalInterface
interface INoReturnNoParam {
    void test();
}

//无返回值有一个参数的功能接口
@FunctionalInterface
interface INoReturnOneParam {
    void test(int a);
}

//无返回值两个参数的功能接口
@FunctionalInterface
interface INoReturnTwoParam {
    void test(int a, int b);
}

//有返回值无参数的功能接口
@FunctionalInterface
interface IHasReturnNoParam {
    int test();
}

//有返回值一个参数的功能接口
@FunctionalInterface
interface IHasReturnOneParam {
    int test(int a);
}

//有返回值两个参数的功能接口
@FunctionalInterface
interface IHasReturnTwoParam {
    int test(int a, int b);
}